#ifndef GATEWAYCONFIG_H
#define GATEWAYCONFIG_H

#include <QObject>

class GateWayConfig {
public:
  explicit GateWayConfig(const QString &fileName = "./gateway_config.json");

  void addConnected(const QPair<QString, int> &conn) {
    for (auto &[_host, _port] : connected_history) {
      if (_port == conn.first && _host == conn.second)
        return;
    }
    connected_history.append(conn);
  }

  void setLastConnected(const QPair<QString, int> &conn) {
    last_connected = {conn.first, conn.second};
    addConnected(conn);
  }

  void setLastBord(int bord) { last_bord = bord; }

  QList<QPair<QString, int>> getConnectedList() const {
    return connected_history;
  }

  inline QPair<QString, int> getLastConnected() const { return last_connected; }

  inline QList<int> getBordList() const { return bord_list; }

  inline int getLastBord() const { return last_bord; }

  void SaveToFile();

private:
  QString file_name;

  QList<QPair<QString, int>> connected_history;

  QPair<QString, int> last_connected;

  QList<int> bord_list;

  int last_bord;
};

#endif // GATEWAYCONFIG_H
